#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/12/3 11:06
# @Author  : chenyj
# @File    : PythonTpips.py
# @Software: IntelliJ IDEA
import json
from operator import itemgetter
import itertools
def duplicate_removal(list_data):
    """
    列表去重，
    :param list_data:
    :return:

    亦可用于检测所有项目是否相等
    len(set(list_data)) == 1
    """
    return list(set(list_data))


def split_list(list_data, split_num):
    """
    列表分段
    :param list_data:
    :param split_num:
    :return:
    """
    return [list_data[i : i + split_num] for i in range(0, len(list_data), split_num)]


def split_del(list_data):
    '''
    Delete the All element of the list
    '''
    del list_data[:]
    print(list_data)


def zip_for_morelist():
    text = ['get', 'real', 'with', 'python']
    numbers = [1, 2, 3, 4, 5]
    for number, text in zip(numbers, text):
        print(f'{number} --> {text}')


def dict_merge():
    x = {
        'a': 1,
        'b': 2
    }
    y = {
        'b': 3,
        'd': 4
    }
    z = {**x, **y}
    print(z)


def dict_orderby_value():
    d = {
        'a': 4,
        'b': 3,
        'c': 2,
        'd': 1
    }
    sorted(d.items(), key=lambda x: x[1])


def beauty_print(dict_data):
   # This function takes a dictionary as an argument and prints it in a more readable format
   json.dumps(dict_data, indent=4, sort_keys=True)


def del_duplicate_in_list(list_data):
    """
    删除列表中重复的元素
    :param list_data:
    :return:
    """
    return list(set(list_data))


def get_multiitem_from_iter(iter):
    itemgetter(1,3)(iter)


def get_all_sort_from_str(str):
    [print(p) for p in itertools.permutations(str)]


def all_usage(list):
    print(all(list))
